package main

import (
	"encoding/json"
	"fmt"
	"net/url"
)

func main() {
	s := "postgres://user:pass@host.com:5432/path?k=v#f"

	u, err := url.Parse(s)
	if err != nil {
		panic(err)
	}
	kvs, _ := json.Marshal(u)
	fmt.Println(string(kvs))
}
